/*
    filename is D:\Projects\sxwf-webapp\src\routes\index.js
    Created by guangluo on 08/14/2020
*/

import React from 'react'
import styles from './styles.less'

import {
  Route,
} from 'dva/router';

import Header from '../components/Header'
import ThreeList from './ThreeLists'
import HomePage from './HomePage'
import ProjectItems from './ThreeLists/pages/Project/Items'
import ProjectDetails from './ThreeLists/pages/Project/Details'

import TaskItems from './ThreeLists/pages/Task/Items'
import TaskDetails from './ThreeLists/pages/Task/Details'

import ResponsibilityItems from './ThreeLists/pages/Responsibility/Items'
import ResponsibilityDetails from './ThreeLists/pages/Responsibility/Details'
import IndicatorAnaysis from './IndicatorAnaysis'
import IndicatorAnaysisDetails from './IndicatorAnaysis/Details'

import WorkStation from './workStation'
import FilterBox from './components/workStation/FilterBox'
import eventDetail from './components/workStation/eventDetail'
import eventDetailItem from './components/workStation/eventDetailItem'
import GenenalSearch from './genenalSearch'
import ArticleSearch from './ArticleSearch'
import AdvancedSearch from './AdvancedSearch'
import ArticleSearchDetail from './ArticleSearchDetail'

const locationData = {
  '/App/HomePage': '无废城市',
  '/App/threeLists': '三张清单',
  '/App/projectItems': '项目清单',
  '/App/projectDetails': '项目详情',
  '/App/taskItems': '任务清单',
  '/App/taskDetails': '任务详情',
  '/App/responsibilityItems': '责任清单',
  '/App/responsibilityDetails': '责任详情',
  '/App/articleSearchDetail': '综合服务查询',
  '/App/articleSearch': '综合服务查询',
  '/App/advancedSearch': '综合服务查询',
  '/App/integratedQuery': '综合服务查询',
  '/App/indicatorAnaysis': '指标分析',
}

export default class Home extends React.Component {
  state = {
    title: '',
  }

  componentDidMount() {
    this.getTitle()
  }

  static getDerivedStateFromProps(nextProps, prevState) {
    if (locationData[nextProps.location.pathname] !== prevState) {
      return {
        title: locationData[nextProps.location.pathname]
      }
    }

    return null
  }

  goBack = () => {
    this.props.history.go(-1)
  }

  getTitle = () => {
    this.setState({
      title: locationData[this.props.location.pathname]
    })
  }

  render() {
    return (
      <div className={styles.wrapper}>
        <Header showBack title={this.state.title} goBack={this.goBack} />

        {/* <Route path="/" component={HomePage} /> */}

        <Route path="/App/HomePage" component={HomePage} />
        <Route path="/App/threeLists" component={ThreeList} />
        <Route path="/App/indicatorAnaysis" component={IndicatorAnaysis} />
        <Route path="/App/indicatorDetails" component={IndicatorAnaysisDetails} />
        <Route path="/App/workbench" component={WorkStation} />
        <Route path="/App/filterBox" component={FilterBox} />
        <Route path="/App/eventDetail" component={eventDetail} />
        <Route path="/App/eventDetailItem" component={eventDetailItem} />
        <Route path="/App/announcement" component={ThreeList} />
        <Route path="/App/documentManagement" component={ThreeList} />
        <Route path="/App/managementSystem" component={ThreeList} />
        <Route path="/App/corporateInformation" component={ThreeList} />
        <Route path="/App/integratedQuery" component={GenenalSearch} />

        <Route path="/App/articleSearchDetail" component={ArticleSearchDetail} />
        <Route path="/App/articleSearch" component={ArticleSearch} />
        <Route path="/App/advancedSearch" component={AdvancedSearch} />

        <Route path="/App/taskItems" component={TaskItems} />
        <Route path="/App/taskDetails" component={TaskDetails} />
        <Route path="/App/projectItems" component={ProjectItems} />
        <Route path="/App/projectDetails" component={ProjectDetails} />
        <Route path="/App/responsibilityItems" component={ResponsibilityItems} />
        <Route path="/App/responsibilityDetails" component={ResponsibilityDetails} />
      </div>
    )
  }
}
